import { defineStore } from 'pinia';
import { Local } from '/@/utils/storage';
import { refreshToken } from '/@/utils/refreshToken';
/**
 * 用户信息
 * @methods setUserInfos 设置用户信息
 */
export const useUserInfo = defineStore('userInfo', {
	state: (): any => ({
		userInfos: {}, // 用户信息
	}),
	actions: {
		async setUserInfos() {
			// 存储用户信息到浏览器缓存
			if (Local.get('userInfo')) {
				this.userInfos = Local.get('userInfo');
			} else {
				await refreshToken();
			}
		},
	},
});
